<template>
	<view class="container">
		<view style="display: flex;flex-direction: row;align-items: center;height: 100rpx;margin-left: 20rpx;margin-top: 20rpx;">
			<u-tabs :list="titleList" :scrollable="false" :current="current" @click="tabClick" lineColor="#5511ec" :activeStyle="{fontWeight: 'bold'}"></u-tabs>
		</view>
		<view style="width: 750rpx;display: flex;flex-direction: row;flex-wrap: wrap;align-content: flex-start;" class="content">
			<view v-for="(item, index) in itemList" :key='index' @click="guestHandle(item)"
			style="display: flex;flex-direction: column;margin-top: 20rpx;background-color: #FFF;width: 345rpx;margin-left: 20rpx;">
				<image :src="item.avatarUrl" mode='aspectFill' style="width: 100%;height: 400rpx;"></image>
				<view style="padding: 16rpx;">
					<view style="font-size: 28rpx;" class="limitLineNumOfTwo">{{item.nickname}}</view>
					<view style="margin-top: 10rpx;color: #fa3534;">¥{{item.sellingPrice}}/小时</view>
				</view>
			</view>
		</view>
		<view style="padding-top: 300rpx;" v-if='showEmpty'>
			<u-empty text="暂无数据" mode="list"></u-empty>
		</view>
	</view>
</template>

<script>
	import { common } from '@/api/common.js'
	export default{
		components: {},
		data() {
			return {
				page: 1,
				size: 20,
				itemList: [],
				showEmpty: false,
				isLastPage: false,
				titleList: [{name: '女生'}, {name: '男生'}],
				current: 0,
				tagId: '',
				title: ''
			}
		},
		onLoad() {
			this.tagId = this.$Route.query.tagId
			this.title = this.$Route.query.title
			uni.setNavigationBarTitle({
				title: this.title
			})
			this.getItemList()
		},
		onPullDownRefresh() {
			this.page = 1
			this.getItemList()
		},
		onReachBottom() {
			if(this.isLastPage) {
				return
			}
			this.getItemList()
		},
		methods:{
			tabClick(item){
				console.log('当前活动', item)
				this.current = item.index
				this.getItemList()
			},
			getItemList() {
				common.operateActionGet('/userForGuest/', {
					page: this.page,
					size: this.size,
					checkStatus: 'PASS',
					gender: this.current==1?'M':'W',
					tag: this.tagId
				}).then(res => {
					uni.stopPullDownRefresh();
					if (res.data.code == 10000) {
						if(this.page == 1){
							this.itemList = []
						}
						var list = res.data.data.list
						this.itemList = [...this.itemList, ...list]
						this.showEmpty = this.itemList.length<1
						if (res.data.data.next) {
							this.page += 1
						} else {
							this.isLastPage = true
						}
					}
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	
</style>
